package davidtps.godutch.adapter;

import java.util.List;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import davidtps.godutch.activity.R;
import davidtps.godutch.adapter.base.AdapterBase;
import davidtps.godutch.business.BusinessUser;
import davidtps.godutch.controls.SlideMenuViewItem;
import davidtps.godutch.model.ModelUser;

public class AdapterUserManagerView extends AdapterBase {
	private BusinessUser mBusinessUser;
	
	private class Holder{
		ImageView ivUserImage;
		TextView tvUserName;
	}
	
	public AdapterUserManagerView(Context pContext) {
		super(pContext, null);
		mBusinessUser = new BusinessUser(pContext);
		List<ModelUser> _ModelUsers = mBusinessUser.queryNoHideUsers();
		setList(_ModelUsers);
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		Holder _Holder;
		if(convertView==null){
			convertView = getLayoutInflater().inflate(R.layout.layout_usermanager_item, null, true);
			
			_Holder = new Holder();
			
			_Holder.ivUserImage = (ImageView)convertView.findViewById(R.id.ivUserImage);
			_Holder.tvUserName = (TextView)convertView.findViewById(R.id.tvUserName);
			convertView.setTag(_Holder);
		}else{
			_Holder = (Holder)convertView.getTag();
		}
		
		ModelUser _ModelUser =  (ModelUser) getList().get(position);
		_Holder.ivUserImage.setBackgroundResource(R.drawable.user_small_icon);
		_Holder.tvUserName.setText(_ModelUser.getUserName());
		
		return convertView;
	}

}
